﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using ToolKit.Mvvm.Attributes;

namespace ToolKit.Mvvm.Extensions
{
    public static class DependencyExtension
    {
        public static List<Type> GetDependenceInjectionTypes(this Assembly assembly)
        {
            var list = assembly.GetTypes();
            var type = typeof(DependenceInjectionAttribute);
            var result = list.Where(t => t.CustomAttributes.Any(p => p.AttributeType == type)).ToList();

            return result;
        }

        public static IEnumerable<DependenceInjectionAttribute> GetDependenceInjectionAttributes(this Type type)
        {
            var typeInfo = type.GetTypeInfo();
            return typeInfo.GetCustomAttributes<DependenceInjectionAttribute>();
        }
    }
}
